package coco.wx.com.module.user.controller;

import coco.wx.com.module.user.entity.User;
import coco.wx.com.module.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 *  用户前端控制器
 *
 * @author srx
 * @since 2020-10-23
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/wxLogin")
    public ResponseEntity<Object> wxLogin(@RequestParam(value = "code") String code) {

        return userService.wxLogin(code);
    }

    /**
     * 获取微信用户信息
     */
    @GetMapping("/getWxUserInfo")
    public ResponseEntity<Object> getWxUserInfo(@RequestParam(value = "openId") String openId,
                                                @RequestParam(value = "accessToken") String accessToken) {
        return userService.getWxUserInfo(openId, accessToken);
    }

    @PostMapping("/getUserAccountInfo")
    public ResponseEntity<Object> getQuestionsSort(@RequestBody User dto) {

        return userService.getUserAccountInfo(dto);
    }



}
